﻿using System;
using System.ComponentModel;
using System.Windows.Navigation;

namespace Lastfm7
{
    public static class Extensions
    {
        public static void ToProfilePage(this NavigationService service)
        {
            service.Navigate(new Uri("/ProfilePage.xaml", UriKind.Relative));
        }

        public static string Fmt(this string format, params object[] args)
        {
            return string.Format(format, args);
        }

        public static void Raise<TEventArgs>(this EventHandler<TEventArgs> handler, object target, TEventArgs args)
            where TEventArgs : EventArgs
        {
            if (handler != null)
                handler(target, args);
        }

        public static void Raise(this EventHandler handler, object target)
        {
            if (handler != null)
                handler(target, EventArgs.Empty);
        }

        public static void Raise(this PropertyChangedEventHandler handler, object target, string propertyName)
        {
            if (handler != null)
                handler(target, new PropertyChangedEventArgs(propertyName));
        }

    }
}
